package coroutines.cancel

import kotlinx.coroutines.*

class NoCancelTest {
    companion object {
        suspend fun noCancel() {
//            withContext(NonCancellable) {
                var count = 0L
                while (true) {
                    delay(100)
                    println("test ${count++}")
                }
            }
//        }
    }
}

fun main() {
    runBlocking {
        val job = launch { NoCancelTest.noCancel() }

        delay(5000)

        job.cancel()
    }
}